const { defineConfig } = require("@vue/cli-service");
const path = require("path");
/**
 * 
 * @param {String} dir 
 */
function resolve(dir) {

  return path.resolve(dir)
}
let env = process.env.NODE_ENV;
let outputDirName;
switch (env) {
  case "production":
    outputDirName = "proDist"
    break;
  case "test":
    outputDirName = "testDist"
    break;
  default:
    outputDirName = "dist"
}
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  outputDir: outputDirName,
  publicPath: "./",
  lintOnSave: false,
  devServer: {
    port: env === "lex" ? 8081 : 8080,
    proxy: {
      "/api": {
        target: process.env.VUE_APP_BASE_URL,
        pathRewrite: { 
          "^/api": ""
        }
      }
    }
  },
  chainWebpack: config => {
    config.resolve.alias
    
      .set("pages", resolve('src/pages'))
      .set("component", resolve('src/compoment'))
      .set("src", resolve('src'))
      .set("~", resolve("src/pages"))
    config.plugin('html') 
      .tap(args => {
        args[0].title = "港区"
        return args
      })
  }
});

